<cfparam name="dir" default="/">

<CFFILE	Action="Upload" FileField="form.ImageFile" Destination="#request.basepath#images#dir#" 
NameConflict="overwrite" Accept="image/gif, image/pjpeg, image/jpg, image/jpeg, image/png" mode="777">

<cfset thefile = cffile.serverfile>
<cfset thefile = replace(thefile, " ", "", "ALL")>
<cfset thefile = replace(thefile, "&", "", "ALL")>
<cfset thefile = replace(thefile, "_", "", "ALL")>
<cfset thefile = replace(thefile, "(", "", "ALL")>
<cfset thefile = replace(thefile, ")", "", "ALL")>
<cfset thefile = replace(thefile, "?", "", "ALL")>
<cfset thefile = replace(thefile, "<", "", "ALL")>
<cfset thefile = replace(thefile, ">", "", "ALL")>
<cfset thefile = replace(thefile, "@", "", "ALL")>
<cfset thefile = replace(thefile, "!", "", "ALL")>
<cfset thefile = replace(thefile, "*", "", "ALL")>
<cfset thefile = replace(thefile, "^", "", "ALL")>
<cfset thefile = replace(thefile, "%", "", "ALL")>

<cfset fullDespath = "#request.basepath#images#dir##thefile#">
<cfset fullDespath = replacenocase(FullDesPath, "//", "/", "ALL")>

<cfset fullFrompath = "#request.basepath#images#dir##cffile.serverfile#">
<cfset fullFrompath = replacenocase(FullFromPath, "//", "/", "ALL")>

<cfoutput>#fullfrompath#</cfoutput><br />
<cfoutput>#fulldespath#</cfoutput>

<cfif NOT thefile IS cffile.serverfile>
	<cffile action = "rename"  source = "#fullfrompath#" destination = "#fulldespath#">
</cfif>
			
<cfset photo = "#thefile#">
<cfset thumb = "#thefile#">

<cfinclude template = "processimage8.cfm">

<cfif NOT isdefined('url.insert')>
	<cflocation url = "index.cfm?m=imagelibrary&a=default&dir=#form.dir#">
<cfelse>

	<cfif url.insert IS 1> <!---does an insert for the icons in the savings categories--->
        <cfparam name = "fname" default="myform">
        <cfparam name = "ffield" default="myformfield">
        <cfparam name = "Dir" default="/icons/">
        
        <script language = "javascript" type="text/javascript">
        function getImage( fileUrl, fname, ffield )
        {
            window.top.opener.SetUrl( fileUrl, fname, ffield ) ;
            window.top.close() ;
            window.top.opener.focus() ;
        }
        </SCRIPT>
    
        <cfoutput>
        <script language="javascript">
            getImage('#photo#', '#fname#', '#ffield#');
        </script>
        </cfoutput>
	</cfif>

</cfif>